#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
class data{
private:
    int a;
    int sequence[4];
public:
    data(){
    }
    void setdata(int _a){
	a=_a;
	for(int i=0;i<4;i++){
	    sequence[i]=a%10;
	    a=a/10;
	}
    }
    void onestep(){
	int sum1=0;
	int sum2=0;
	sort(sequence,sequence+4);
	for(int i=3;i>=0;i--){
	    cout<<sequence[i];
	    sum2=sum2+sequence[i]*pow(10,3-i);
	}
	cout<<" - ";
	for(int i=0;i<4;i++){
	    cout<<sequence[i];
	    sum1=sum1+sequence[i]*pow(10,i);
	}
	cout<<" = ";
	a=sum1-sum2;
	if(a<1000&&a>=100){
	    cout<<"0";
	}else if(a<100&&a>=10){
	    cout<<"00";
	}else if(a<10&&a>=0){
	    cout<<"000";
        }
	cout<<a;
	cout<<endl;
    }
    int get_a(){
	return a;
    }
};
int main(){
    data D;
    int n;
    cin>>n;
    D.setdata(n);
    while(1){
	D.onestep();
	if(D.get_a()==6174||D.get_a()==0){
	    break;
	}
	D.setdata(D.get_a());
    }
}
